<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人中心 - 员工报工系统</title>
    <link rel="stylesheet" href="/assets/css/frontend.css">
    <style>
        .profile-container {
            max-width: 800px;
            margin: 50px auto;
            padding: 20px;
        }
        .profile-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            padding: 30px;
            margin-bottom: 20px;
        }
        .profile-header {
            text-align: center;
            margin-bottom: 30px;
        }
        .profile-avatar {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background: #4A90E2;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 36px;
            font-weight: bold;
            margin: 0 auto 20px;
        }
        .profile-info {
            margin-bottom: 30px;
        }
        .info-item {
            display: flex;
            justify-content: space-between;
            padding: 15px 0;
            border-bottom: 1px solid #f0f0f0;
        }
        .info-label {
            font-weight: bold;
            color: #333;
        }
        .info-value {
            color: #666;
        }
        .bind-section {
            text-align: center;
            padding: 30px;
            border: 2px dashed #ddd;
            border-radius: 10px;
            margin: 20px 0;
        }
        .bind-title {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 15px;
            color: #333;
        }
        .bind-desc {
            color: #666;
            margin-bottom: 20px;
        }
        .bind-btn {
            background: #4A90E2;
            color: white;
            border: none;
            padding: 12px 30px;
            border-radius: 6px;
            font-size: 16px;
            cursor: pointer;
            transition: background 0.3s;
        }
        .bind-btn:hover {
            background: #357ABD;
        }
        .bind-btn:disabled {
            background: #ccc;
            cursor: not-allowed;
        }
        .qr-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 1000;
        }
        .qr-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: white;
            padding: 30px;
            border-radius: 10px;
            text-align: center;
            max-width: 400px;
            width: 90%;
        }
        .qr-title {
            font-size: 20px;
            font-weight: bold;
            margin-bottom: 20px;
        }
        .qr-code {
            margin: 20px 0;
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        .qr-tips {
            color: #666;
            font-size: 14px;
            line-height: 1.5;
        }
        .close-btn {
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 24px;
            cursor: pointer;
            color: #999;
        }
        .bind-status {
            padding: 15px;
            border-radius: 5px;
            margin: 10px 0;
        }
        .bind-status.success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        .bind-status.error {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        .bind-status.pending {
            background: #fff3cd;
            color: #856404;
            border: 1px solid #ffeaa7;
        }
        .bind-steps {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
        }
        .bind-steps h4 {
            margin-bottom: 15px;
            color: #333;
        }
        .bind-steps ol {
            margin: 0;
            padding-left: 20px;
        }
        .bind-steps li {
            margin-bottom: 8px;
            color: #666;
            line-height: 1.5;
        }
    </style>
</head>
<body>
    <div class="profile-container">
        <div class="profile-card">
            <div class="profile-header">
                <div class="profile-avatar">
                    {$user.nickname|substr=0,1|strtoupper}
                </div>
                <h2>{$user.nickname}</h2>
                <p>员工账号</p>
            </div>
            
            <div class="profile-info">
                <div class="info-item">
                    <span class="info-label">用户名：</span>
                    <span class="info-value">{$user.username}</span>
                </div>
                <div class="info-item">
                    <span class="info-label">手机号：</span>
                    <span class="info-value">{$user.mobile}</span>
                </div>
                <div class="info-item">
                    <span class="info-label">邮箱：</span>
                    <span class="info-value">{$user.email}</span>
                </div>
                <div class="info-item">
                    <span class="info-label">注册时间：</span>

                </div>
            </div>
            
            <div class="bind-section">
                <div class="bind-title">绑定微信小程序</div>
                <div class="bind-desc">
                    生成二维码，用微信小程序扫描即可绑定账号
                </div>
                
                <div class="bind-steps">
                    <h4>操作步骤：</h4>
                    <ol>
                        <li>点击下方"生成绑定二维码"按钮</li>
                        <li>输入您的密码</li>
                        <li>用微信小程序扫描生成的二维码</li>
                        <li>完成绑定</li>
                    </ol>
                </div>
                
                <div id="bindStatus" class="bind-status" style="display: none;"></div>
                
                <button id="bindBtn" class="bind-btn" onclick="generateBindQR()">
                    生成绑定二维码
                </button>
            </div>
        </div>
    </div>
    
    <!-- 二维码弹窗 -->
    <div id="qrModal" class="qr-modal">
        <div class="qr-content">
            <span class="close-btn" onclick="closeQRModal()">&times;</span>
            <div class="qr-title">请用小程序扫码绑定</div>
            <div id="qrCode" class="qr-code"></div>
            <div class="qr-tips">
                <p>1. 打开微信小程序</p>
                <p>2. 点击"微信登录"</p>
                <p>3. 点击"绑定员工账号"</p>
                <p>4. 选择"扫码绑定"</p>
                <p>5. 扫描此二维码完成绑定</p>
            </div>

        </div>
    </div>
    
    <script src="/assets/js/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/qrcodejs/1.0.0/qrcode.min.js"></script>
    <script>
        
        // 生成绑定二维码
        function generateBindQR() {
            var password = prompt('请输入您的密码以生成绑定二维码：');
            if (!password) {
                return;
            }
            
            $('#bindBtn').prop('disabled', true).text('生成中...');
            
            // 直接生成包含用户名和密码的二维码内容
            var qrContent = 'bind:{$user.username}:' + password;
            showQRModal(qrContent);
            $('#bindBtn').prop('disabled', false).text('重新生成');
        }
        
        // 显示二维码弹窗
        function showQRModal(qrContent) {
            $('#qrCode').html('');
            new QRCode(document.getElementById("qrCode"), {
                text: qrContent,
                width: 200,
                height: 200
            });
            $('#qrModal').show();
            $('#bindBtn').prop('disabled', false).text('重新生成');
        }
        
        // 关闭二维码弹窗
        function closeQRModal() {
            $('#qrModal').hide();
        }
        
        // 页面加载完成
        $(document).ready(function() {
            // 检查是否已绑定
            // 这里可以添加检查逻辑
        });
    </script>
</body>
</html>
